/*
 * Copyright (C) 2020 Agrui
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef EVENT_H
#define EVENT_H


#include <types.h>
#include <MessageHandler.h>
#include <RegistrantList.h>
#include <Bundle.h>
#include <class.h>

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_NICK_NAME_LEN       10

CLASS(Event) {
    boolean mState;
    boolean mAutoReset;
    RegistrantList* mRegList;
    Bundle mBundle;
    char mNickName[MAX_NICK_NAME_LEN];

    /*Constructor*/
    void (*__init__)(Event* event, const char* name, boolean state, boolean autoReset);
    /*Destructor*/
    void (*__deinit__)(Event* event);

    /*Class Interface*/
    char* (*getName)();
    Bundle (*getBundle)();
    boolean (*getState)();
    void (*updateState)(boolean state);
    void (*autoResetState)();
    void (*registerStateChanged)(Handler* handler, int what, void* obj);
    void (*unregisterStateChanged)(Handler* handler);
};


typedef struct EventData_TAG {
    char mNickName[MAX_NICK_NAME_LEN];
    boolean mState;
} EventData;


#ifdef __cplusplus
}
#endif

#endif
